import router from "../router";
import { name } from "../../package";

//进度条
import NProgress from "nprogress";
import "nprogress/nprogress.css";

// 添加路由守卫

router.beforeEach((to, form, next) => {
  NProgress.start(); //开启进度条
  // console.log(to, form, ">>>>>>>>><<<<<<<<");
  //添加路由 校验逻辑
  // if(to.fullPath!='/login'){
  //   next('login');
  // }else{
  next();
  // }
});

router.afterEach((to) => {
  NProgress.done(); //关闭进度条
  try {
    //设置标题
    if (to.meta.name) {
      // 修改项目浏览器名称！ package.name  +  路由的name
      document.querySelector("head title").innerHTML = name + "---" + to.name;
    }
  } catch (err) {
    console.log(err);
  }
});
